package com.huey.oa.service;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huey.oa.model.OaLeave;
import com.huey.oa.mapper.OaLeaveMapper;
import com.huey.db.base.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author huey
 * @since 2021-06-22
 */
@Service
public class OaLeaveService extends BaseService<OaLeaveMapper, OaLeave> {

    /**
     * 获取表格数据
     *
     * @param oaLeave
     * @return
     */
    public IPage<OaLeave> getPageListByEntity(OaLeave oaLeave) {
        LambdaQueryWrapper<OaLeave> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.like(StrUtil.isNotBlank(oaLeave.getProcessInstanceId()), OaLeave::getProcessInstanceId, oaLeave.getProcessInstanceId());
        queryWrapper.like(StrUtil.isNotBlank(oaLeave.getUserId()), OaLeave::getUserId, oaLeave.getUserId());
        queryWrapper.like(StrUtil.isNotBlank(oaLeave.getName()), OaLeave::getName, oaLeave.getName());
        queryWrapper.like(StrUtil.isNotBlank(oaLeave.getType()), OaLeave::getType, oaLeave.getType());
        queryWrapper.like(StrUtil.isNotBlank(oaLeave.getReason()), OaLeave::getReason, oaLeave.getReason());
        queryWrapper.like(StrUtil.isNotBlank(oaLeave.getStatus()), OaLeave::getStatus, oaLeave.getStatus());
        return super.page(oaLeave, queryWrapper);
    }

}
